package com.ruoyi.epidemic.web;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.epidemic.domain.TbSuggest;
import com.ruoyi.epidemic.service.ITbSuggestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author zyc
 * @createDate 2023/3/21 10:16
 */
@RestController
@RequestMapping("/web/suggest")
public class SuggestController {
    @Autowired
    private ITbSuggestService suggestService;


    //用户发布建议信息
    @PostMapping("/push")
    public AjaxResult push(@RequestBody TbSuggest suggest){
       return suggestService.push(suggest);
    }

    //我发布的建议
    @GetMapping("/mySuggest")
    public AjaxResult getByUserId(@RequestParam Long userId){
        return suggestService.getByUserId(userId);
    }

    //用户删除建议信息
    @PostMapping("/delete")
    public AjaxResult  deleteSuggest(@RequestBody TbSuggest tbSuggest){
        int i = suggestService.deleteTbSuggestById(tbSuggest.getId());
        if (i>0){
            return AjaxResult.success("删除成功");
        }else {
            return AjaxResult.error("删除失败");
        }
    }

}
